package org.nf.web.servlet.mapping;

import jakarta.servlet.http.HttpServletRequest;
import org.nf.web.servlet.HandlerExecutionChain;
import org.nf.web.servlet.HttpRequestHandler;
import org.nf.web.servlet.resource.DefaultServletHttpRequestHandler;

/**
 * @author wangliang
 * @date 2024/5/22
 * DefaultServlet请求映射
 * 注意：这个HandlerMapping通常用来映射静态资源或者其他HandlerMapping无法匹配的请求，
 * 因此在众多HandlerMapping的匹配过程中应该是最后一个匹配
 */
public class DefaultServletRequestHandlerMapping extends AbstractHandlerMapping {

    private final HttpRequestHandler httpRequestHandler;

    public DefaultServletRequestHandlerMapping() {
        httpRequestHandler = new DefaultServletHttpRequestHandler();
    }

    @Override
    public HandlerExecutionChain getHandler(HttpServletRequest request) {
        return getHandlerExecutionChain(request, httpRequestHandler);
    }
}
